//
//  ViewTemplate.m
//  Golf
//
//  Created by chengxu on 15/12/21.
//  Copyright © 2015年 Shenzhen Tentinet Technology Co,. Ltd. All rights reserved.
//

#import "ViewTemplate.h"
#import "MY_infoModel.h"

@implementation ViewTemplate

- (instancetype)initWithFrame:(CGRect)frame Model:(MY_infoModel *)model{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self initView:model];
    }
    return self;
}

- (void)initView:(MY_infoModel *)model{
    _titlelbl = [[UILabel alloc]initWithFrame:CGRectMake(15, 0, 60, self.frame.size.height)];
    _titlelbl.text = model.title;
    _titlelbl.font = [UIFont systemFontOfSize:14];
    _titlelbl.textColor = HexRGB(0x4d4d4d);
    [self addSubview:_titlelbl];
    UITextField *promptfid = [[UITextField alloc]initWithFrame:CGRectMake(_titlelbl.golf_right +10, 0,self.frame.size.width - _titlelbl.frame.size.width - 50, self.frame.size.height)];
    if (![model.btntitle isEqualToString:@""]) {
        [promptfid setFrame:CGRectMake(_titlelbl.golf_right + 10, 0,kScreenWidth - _titlelbl.golf_right - 110, self.frame.size.height)];
        self.promptbtn = [[UIButton alloc]initWithFrame:CGRectMake(promptfid.golf_right , 10, 90, self.frame.size.height - 20)];
        [self.promptbtn setTitle:model.btntitle forState:0];
        [self.promptbtn setTitleColor:[UIColor whiteColor] forState:0];
        self.promptbtn.titleLabel.font = [UIFont systemFontOfSize:14];
        self.promptbtn.layer.cornerRadius = 5;
        
        self.promptbtn.backgroundColor = HexRGB(0x878787);
        [self addSubview:self.promptbtn];
        
    }
    promptfid.placeholder = model.prompt;
    promptfid.tag = model.Tag;
    promptfid.font = [UIFont systemFontOfSize:14];
    promptfid.textColor = HexRGB(0x262626);
    if (model.isclear) {
        promptfid.clearButtonMode = UITextFieldViewModeWhileEditing;
    }
    [self addSubview:promptfid];
}

@end
